<meta charset="utf-8">
<?php
/**
 * Created by PhpStorm.
 * User: Dinglf
 * Date: 2016/9/19 0019
 * Time: 15:25
 */
if($_POST['title'] != null && $_POST['content'] != null)
{
    $title = $_POST['title'];
    $content = $_POST['content'];
    $content = addslashes($content);
    $sql = new PDO('mysql:host=localhost;dbname=lyon','lyon','lyon123');
    $sqll = "insert into lyon_text(title,content) values('$title','$content')";
    if($sql->exec($sqll))
    {
        echo "<meta http-equiv='Refresh' content='0.5; url=/index.php' />";
    }
    else
    {
        echo "<script>alert('添加失败');history.go(-1);</script>";
    }
}
else
{
    echo "<script>alert('请输入标题和内容');history.go(-1);</script>";
}

?>